(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives
	     '("gnu" . "http://elpa.gnu.org/packages/") t)
(package-initialize)
(unless package-archive-contents
  (package-refresh-contents))
(unless (package-installed-p 'use-package)
  (package-install 'use-package)
  )
(eval-when-compile
  (require 'use-package))
;auto update packages
(use-package auto-package-update
  :ensure
  :config
  (setq auto-package-update-delete-old-versions t)
  (setq auto-package-update-hide-results t)
;  (setq auto-package-update-prompt-before-update t)
  (auto-package-update-maybe))

(use-package flycheck
  :ensure
  :init (global-flycheck-mode))
(use-package projectile
  :ensure
  :init  (  setq projectile-project-search-path '("~/projects/"))
  :bind (
	 ("s-p" . projectile-command-map)
	 ("C-c p" . projectile-command-map)
	 )
  :config
  (projectile-mode +1)
  )

(use-package flycheck-rust
:ensure
  )
(use-package dracula-theme
  :ensure
  :init (load-theme 'dracula t)
  )
(use-package ivy
  :ensure
  :init  ;(
;	  (setq ivy-use-virtual-buffers t)
	   (ivy-mode 1)
  )
(use-package counsel
  :ensure
  :bind (
	 ("<f1> v" . counsel-describe-variable)
	 ("<f1> l" . counsel-find-library)
	 ("<f2> i" . counsel-info-lookup-symbol)
	 ("<f2> u" . counsel-unicode-char)
	 ("<f2> j" . counsel-set-variable)
  )
  :config (counsel-mode 1)
  )
(use-package telega
  :ensure
  :bind (:map global-map (kbd "C-c t") telega-prefix-map)
  )
(use-package auto-complete
  :ensure
  :config (ac-config-default)
  )
(use-package wakatime-mode
  :ensure
  :init
  (global-wakatime-mode)
 ; (setq wakatime-cli-path '("/usr/bin/env wakatime"))
  )
(use-package magit
  :ensure
  :init (setq magit-view-git-manual-method 'man)
  )

(use-package yasnippet
  :ensure
  :init (yas-global-mode 1))
(use-package undo-tree
  :ensure
  :init (global-undo-tree-mode))
(use-package ibuffer-vc
:ensure
  )
(use-package ibuffer-projectile
:ensure
  )
(add-hook 'ibuffer-hook
    (lambda ()
      (ibuffer-projectile-set-filter-groups)
      (unless (eq ibuffer-sorting-mode 'alphabetic)
        (ibuffer-do-sort-by-alphabetic))))
(use-package rich-minority
  :ensure
  :config (rich-minority-mode 1)
  )
(setq rm-blacklist
      (format "^ \\(%s\\)$"
              (mapconcat #'identity
                         '("Fly.*" "Projectile.*" "waka" "ivy" "counsel" "yas" "Undo-Tree")
                         "\\|")))

(use-package nlinum
  :ensure
  :init (global-nlinum-mode)
  )

(add-to-list 'package-pinned-packages '(telega . "melpa-stable"))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-safe-themes
   '("3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" "84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279" "81c3de64d684e23455236abde277cda4b66509ef2c28f66e059aa925b8b12534" default))
 '(package-selected-packages
   '(flycheck-inline just-mode company-tabnine company rustic dot-mode doom-modeline lsp-ui lsp-mode wakatime-mode racer pycarddavel flymake-rust unobtrusive-magit-theme flycheck-cython ivy cargo flycheck-rust dracula-theme telega rust-mode projectile))
 '(wakatime-python-bin nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
;; rust-mode settings
;(add-hook 'rustic-mode-hook
;          (lambda () (setq indent-tabs-mode nil)))

;(setq rustic-format-on-save t)
;;auto-pair
 (defun electric-pair ()
      "If at end of line, insert character pair without surrounding spaces.
    Otherwise, just insert the typed character."
      (interactive)
      (if (eolp) (let (parens-require-spaces) (insert-pair)) (self-insert-command 1)))
(add-hook 'rust-mode-hook 'cargo-minor-mode)



(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
;; (setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
;;;for ivy

;;;rust completion
;(add-hook 'rustic-mode-hook  #'racer-mode)
;(add-hook 'racer-mode-hook #'eldoc-mode)
;(define-key rustic-mode-map (kbd "TAB") #'company-indent-or-complete-common)
;default font: Fira
    (add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font" ))
    (set-face-attribute 'default t :font "FiraCode Nerd Font" )
(load "~/.emacs.d/rust_conf")
; confirm by y and n
(defalias 'yes-or-no-p 'y-or-n-p)
					; disable backup files
(setq make-backup-files nil)
					; disable menu bar
(menu-bar-mode -1)
					;disable tool bar
(tool-bar-mode -1)
(load "~/.emacs.d/ui_customize")
(load "~/.emacs.d/markdown_conf")
(use-package dot-mode
  :ensure
  :init (global-dot-mode)
  :bind((
	"C-." . dot-mode-execute
	)
	(
	 "C-M-." . dot-mode-override
	 )
	)
  )
(use-package just-mode
  :ensure
  )
(use-package flycheck-inline
  :ensure
  :init (global-flycheck-inline-mode)
  )
